package com.example.myapplication.shortvideo.utils;

import com.danikula.videocache.HttpProxyCacheServer;
import com.example.myapplication.AppApplication;

/**
 * @Description: 视频缓存
 * @Author: rongfeng
 * @CreateDate: 2019/7/8 16:38
 */
public class HttpProxyCacheUtil {
    private HttpProxyCacheServer proxy;

    private HttpProxyCacheUtil() {
    }

    private static volatile HttpProxyCacheUtil instance = null;

    public static HttpProxyCacheUtil getInstance() {
        if (instance == null) {
            synchronized (HttpProxyCacheUtil.class) {
                if (instance == null) {
                    instance = new HttpProxyCacheUtil();
                }
            }
        }
        return instance;
    }

    public HttpProxyCacheServer getProxy() {
        if (proxy == null) {
            proxy = new HttpProxyCacheServer.Builder(AppApplication.getInstance()).
                     maxCacheSize(1024 * 1024 * 1024)       // 1 Gb for cache
                    .build();
        }
        return proxy;
    }

}
